<template>
	<!-- <view :class="{ 'uni-card--full': isFull === true || isFull === 'true', 'uni-card--shadow': isShadow === true || isShadow === 'true' }" class="uni-card" @click="onClick"> -->
		<view :class="{ 'uni-card--full': isFull === true || isFull === 'true', 'uni-card--shadow': isShadow === true || isShadow === 'true' }" class="uni-card" >
		
		
		<view v-if="mode === 'style'" class="uni-card__thumbnailimage">
			<view class="uni-card__thumbnailimage-box">
				<image class="uni-card__thumbnailimage-image" :src="thumbnail" mode="aspectFill" />
			</view>
			<view v-if="title" class="uni-card__thumbnailimage-title" style="white-space:nowrap; "><text class="uni-card__thumbnailimage-title-text" >{{ title }}</text></view>
		</view>
		<view v-if="mode === 'title'" class="uni-card__title">
			<view class="uni-card__title-header">
				<image class="uni-card__title-header-image" :src="thumbnail" mode="scaleToFill" />
			</view>
			<view class="uni-card__title-content">
				<text class="uni-card__title-content-title">{{ title }}</text>
				<text class="uni-card__title-content-extra">{{ extra|dateFormat}}</text>
			</view>
			<view class="uni-card__title-content1" >
				<view class="uni-card__title-content-title"  >
				 <!-- <uni-icons v-if="showUpImg"  type="star" size="14" color="#ff8700" @click="follow"/> -->
				
				<uni-icons :type="'star'+forbid"  size="18" color="#ff8700" @tap="hotToggle(fuid,thumbnail,title)"/>
				  
<!-- 				<image @tap="hotToggle" :src="'/static/HM-search/attention'+forbid+'.png'"></image>
 -->				
				关注
				
				</view>
				 
				
				 <text class="uni-card__title-content-extra">
				<uni-icons type="phone-filled" size="13" color="#b9b8c2"/>
				{{phone}}
				</text> 
				</view>
		</view>
		<!-- 标题 -->
		<view v-if="mode === 'basic' && title" class="uni-card__header">
			<view v-if="thumbnail" class="uni-card__header-extra-img-view">
				<image :src="thumbnail" class="uni-card__header-extra-img" />
			</view>
			<text class="uni-card__header-title-text">{{ title }}</text>
			<text v-if="extra" class="uni-card__header-extra-text">{{ extra }}</text>
		</view>
		<!-- 内容 -->
		<view class="uni-card__content uni-card__content--pd">
			<view v-if="mode === 'style' && extra" class=""><text class="uni-card__content-extra">{{ extra }}</text></view>
			<slot />
		</view>
		<!-- 底部 -->
		<view v-if="note" class="uni-card__footer">
			<slot name="footer">
				<text class="uni-card__footer-text">{{ note }}</text>
			</slot>
		</view>
	</view>
</template>

<script>
	/**
	 * Card 卡片
	 * @description 卡片视图组件
	 * @tutorial https://ext.dcloud.net.cn/plugin?id=22
	 * @property {String} title 标题文字
	 * @property {String} extra 标题额外信息
	 * @property {String} note 标题左侧缩略图
	 * @property {String} thumbnail 底部信息
	 * @property {String} mode = [basic|style|title] 卡片模式
	 * 	@value basic 基础卡片
	 * 	@value style 图文卡片
	 * 	@value title 标题卡片
	 * @property {Boolean} isFull = [true | false] 卡片内容是否通栏，true 时将去除padding值
	 * @property {Boolean} isShadow = [true | false] 卡片内容是否开启阴影
	 * @event {Function} click 点击 Card 触发事件
	 * @example <uni-card title="标题文字" thumbnail="https://img-cdn-qiniu.dcloud.net.cn/new-page/uni.png" extra="额外信息" note="Tips">内容主体，可自定义内容及样式</uni-card>
	 */
	export default {
		
		name: 'UniCard',
		props: {
			title: {
				type: String,
				default: ''
			}, // 标题
			extra: {
				type: String,
				default: ''
			}, // 扩展信息
			note: {
				type: String,
				default: ''
			}, // Tips
			thumbnail: {
				type: String,
				default: ''
			}, // 缩略图
			// 卡片模式 ， 可选值 basic：基础卡片 ；style ：图文卡片 ； title ：标题卡片
			mode: {
				type: String,
				default: 'basic'
			},
			isFull: {
				// 内容区域是否通栏
				type: Boolean,
				default: true
			},
			isShadow: {
				// 是否开启阴影
				type: Boolean,
				default: false
			},
			fuid: {
				// 是否开启阴影
				type: String,
				default: ''
			},
			fimg: {
				// 是否开启阴影
				type: String,
				default: ''
			},
			phone:{
				// 是否开启阴影
				type: String,
				default: ''
			}
			
		},
		
		data() {
			return {
				uid:uni.getStorageSync('userInfo').uid,
				isfollow:false,
				forbid: '',
				
			}
		},
		filters:{
			dateFormat(value){
				
				let timearr = value.replace(" ", ":").replace(/\:/g, "-").split("-");
				
				//console.log(timearr);
				
				let timestr = "" + timearr[1].split("")[1] + "-" + timearr[2] + "\t" +  ""
				
				
				return timestr
			}
		},
		methods: {
			//热门搜索开关
			hotToggle(fuid,fimg,title) {
				if(this.uid){
					
				this.forbid = this.forbid ? '' : '-filled';
				this.isfollow=!this.isfollow;
				
				const sendData = {
					"uid": this.uid,
					"fuid":fuid,
					"img":fimg,
					"pname":title
				};
				
					uni.request({
						url: this.userApi + '/addfollowp', //仅为示例，并非真实接口地址。
						data: sendData,
						dataType: 'json',
						method: 'POST',
						header: {
							'content-type': 'application/json' // 微信默认就是
						},
						success: res => {
							if (res.statusCode !== 404) {
								console.log(res.data);
				
								
							
							} else {
								console.log('数据没有');
							}
						}
					});
				
				}else{
					uni.showModal({
						title: '消息',
						content: '请先登陆！',
						showCancel: false,
						confirmText: '确定'
					});
				}
				
				
				
				
				
				
				
				
				
				
			},
			onClick() {
				this.$emit('click')
			},
		 
			
		}
	}
</script>

<style scoped>
	.uni-card {
		/* #ifndef APP-NVUE */
		display: flex;
		flex: 1;
		box-shadow: 0 0 0 rgba(0, 0, 0, 0);
		/* #endif */
		margin: 12px;
		background-color: #ffffff;
		position: relative;
		flex-direction: column;
		overflow: hidden;

	}

	.uni-card__thumbnailimage {
		position: relative;
		flex-direction: column;
		justify-content: center;
		height: 150px;
		overflow: hidden;
	}

	.uni-card__thumbnailimage-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex: 1;
		flex-direction: row;
		overflow: hidden;
	}

	.uni-card__thumbnailimage-image {
		flex: 1;
	}

	.uni-card__thumbnailimage-title {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		position: absolute;
		bottom: 0;
		left: 0;
		right: 0;
		flex-direction: row;
		padding: 16rpx 24rpx;
		background-color: rgba(0, 0, 0, 0.4);
	}

	.uni-card__thumbnailimage-title-text {
		flex: 1;
		font-size: 28rpx;
		color: #fff;
	}

	.uni-card__title {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		padding: 10px;
	
	}

	.uni-card__title-header {
		width: 15%;
		height: 40px;
		overflow: hidden;
		
	}

	.uni-card__title-header-image {
		width: 40px;
		height: 40px;
	}

	.uni-card__title-content {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		padding-left: 10px;
		height: 40px;
		overflow: hidden;
		width: 30%;


	}
	.uni-card__title-content1 {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		padding-left: 10px;
		height: 40px;
		overflow: hidden;
		width: 70%;
		text-align: right;
	
	
	}

	.uni-card__title-content-title {
		font-size: 30rpx;
		line-height: 22px;
		lines: 1;
	}

	.uni-card__title-content-extra {
		font-size: 26rpx;
		line-height: 35rpx;
		color: #999;
	}

	.uni-card__header {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		position: relative;
		flex-direction: row;
		padding: 24rpx;
		align-items: center;
	
	}

	.uni-card__header-title {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		margin-right: 16rpx;
		justify-content: flex-start;
		align-items: center;
	}

	.uni-card__header-title-text {
		font-size: 32rpx;
		flex: 1;
		/* #ifndef APP-NVUE */
		white-space: nowrap;
		/* #endif */
		/* #ifdef APP-NVUE */
		lines: 1;
		/* #endif */
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.uni-card__header-extra-img {
		height: 40rpx;
		width: 40rpx;
		margin-right: 16rpx;
	}

	.uni-card__header-extra-text {
		flex: 1;
		margin-left: 16rpx;
		font-size: 28rpx;
		text-align: right;
		color: #999;
	}

	.uni-card__content {
		color: #333;
	}

	.uni-card__content--pd {
		padding: 24rpx;
	}

	.uni-card__content-extra {
		font-size: 28rpx;
		padding-bottom: 10px;
		color: #999;
	}

	.uni-card__footer {
		justify-content: space-between;
		padding: 10px;
		
	}

	.uni-card__footer-text {
		color: #999;
		font-size: 28rpx;
	}

	.uni-card--shadow {
	
		/* #ifndef APP-NVUE */
		box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.2);
		/* #endif */
	}

	.uni-card--full {
		margin: 0;
		border-radius: 0;
	}
</style>